<!--
 * @description  :面单档案维护
 * @descriptionDetail:面单档案维护
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-09 22:21:21
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar title="面单档案维护"></theme-navbar>
    <!-- #endif -->
    <view class="content content-bg ifn-content" style="background-color: white">
      <u-form
        class="u-form-m"
        :label-style="labelStyle"
        :model="baseInfo"
        :error-type="['border-bottom', 'message',]"
        label-width="auto"
        label-position="top"
        ref="uForm"
      >
        <u-form-item label="面单号" prop="billCode" :required="true">
          <u-input v-model="baseInfo.billCode" :disabled="isDisabled" placeholder="请输入"></u-input>
          <u-icon
            name="scan" color="primary" size="52"
            @click="scanClick"
          ></u-icon>
        </u-form-item>
        <u-form-item label="登记单位" :required="true">
          <u-input :disabled="true" :custom-style="pointerStyle" v-model="baseInfo.orgName"></u-input>
        </u-form-item>
        <u-form-item label="所属快递公司" class="caseFromClass">
          <auto-input
            absIndex="1"
            :searchData="searchData"
            absClass="caseFromClass"
            placeholder="快递公司模糊查询"
            v-model="baseInfo.expressCompanyName"
            @choiceAutoItem="choiceAutoItem"
            style="width: 100%"
          ></auto-input>
        </u-form-item>
        <u-form-item label="包装数量">
          <u-input type="digit" placeholder="请输入" v-model="baseInfo.packageNum"></u-input>
        </u-form-item>
        <u-form-item label="查获人" prop="getPerson">
          <u-input placeholder="请输入" v-model="baseInfo.getPerson"></u-input>
        </u-form-item>
        <u-form-item label="查获人电话" prop="getPersonTel">
          <u-input type="digit" placeholder="请输入" v-model="baseInfo.getPersonTel"></u-input>
        </u-form-item>
        <u-form-item label="包装形式">
          <u-input placeholder="请输入" v-model="baseInfo.packageStyle"></u-input>
        </u-form-item>
        <u-form-item label="配送地址">
          <u-input placeholder="请输入" v-model="baseInfo.distributionAddr"></u-input>
        </u-form-item>
        <u-form-item label="查获地址" :border-bottom="false">
          <u-input
            type="select" :disabled="true" placeholder="请选择" :custom-style="pointerStyle"
            v-model="baseInfo.provCityCountyName" @click=" (nativeNameSelectShow = true)"
          ></u-input>
        </u-form-item>

        <view class="u-form pa-t8">
          <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color" class="mg-lr-16"></u-gap>
          <fsection :title="title.sendInformation" :customStyle="customConStyle"></fsection>
        </view>
        <u-form-item label="发件人" prop="sender">
          <u-input placeholder="请输入" v-model="baseInfo.sender"></u-input>
        </u-form-item>
        <u-form-item label="发件人电话" prop="sendTel">
          <u-input type="number" placeholder="请输入" v-model="baseInfo.sendTel"></u-input>
        </u-form-item>
        <u-form-item label="发件时间">
          <u-input
            placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="baseInfo.sendTime"
            @click="dateRange = true;"
          ></u-input>
        </u-form-item>
        <u-form-item label="寄件网点">
          <u-input placeholder="请输入" v-model="baseInfo.sendSite"></u-input>
        </u-form-item>
        <u-form-item label="发件地址" :border-bottom="false">
          <view style="display: flex; flex-direction: column; width: 100%">
            <u-input
              type="select" :disabled="true" placeholder="请选择" :custom-style="pointerStyle"
              v-model="baseInfo.issueName" @click=" (issueSelectShow = true)"
            ></u-input>
            <u-line :color="$theme.u_border_color" style="margin-top: 20rpx"></u-line>
          </view>
        </u-form-item>
        <u-form-item prop="address" :border-bottom="false">
          <u-input :border="true" placeholder="发件人详细地址" v-model="baseInfo.sendAddress"></u-input>
        </u-form-item>

        <view class="u-form pa-t8">
          <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color" class="mg-lr-16"></u-gap>
          <fsection title="揽件信息" :customStyle="customConStyle"></fsection>
        </view>
        <u-form-item label="揽件人" prop="packager">
          <u-input placeholder="请输入" v-model="baseInfo.packager"></u-input>
        </u-form-item>
        <u-form-item label="揽件人电话" prop="packagerTel">
          <u-input type="number" placeholder="请输入" v-model="baseInfo.packagerTel"></u-input>
        </u-form-item>
        <u-form-item label="揽件人站点">
          <u-input placeholder="请输入" v-model="baseInfo.packagerSite"></u-input>
        </u-form-item>
        <u-form-item label="揽件时间" :border-bottom="false">
          <u-input
            placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="baseInfo.packagerTime"
            @click="packageDateRange = true;"
          ></u-input>
        </u-form-item>

        <view class="u-form pa-t8">
          <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color" class="mg-lr-16"></u-gap>
          <fsection title="派件信息" :customStyle="customConStyle"></fsection>
        </view>
        <u-form-item label="派件人" prop="dispatcher">
          <u-input placeholder="请输入" v-model="baseInfo.dispatcher"></u-input>
        </u-form-item>
        <u-form-item label="派件人电话" prop="dispatcherTel">
          <u-input type="number" placeholder="请输入" v-model="baseInfo.dispatcherTel"></u-input>
        </u-form-item>
        <u-form-item label="派件时间">
          <u-input
            placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="baseInfo.dispatcherTime"
            @click="dispatchDateRange = true;"
          ></u-input>
        </u-form-item>
        <u-form-item :border-bottom="false" label="派件人地址">
          <view style="display: flex; flex-direction: column; width: 100%">
            <u-input
              type="select" :disabled="true" placeholder="请选择" :custom-style="pointerStyle"
              v-model="baseInfo.dispatchName" @click=" (dispatchSelectShow = true)"
            ></u-input>
            <u-line :color="$theme.u_border_color" style="margin-top: 20rpx"></u-line>
          </view>
        </u-form-item>
        <u-form-item prop="address" :border-bottom="false">
          <u-input :border="true" placeholder="派件人详细地址" v-model="baseInfo.dispatcherAddress"></u-input>
        </u-form-item>

        <view class="u-form pa-t8">
          <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color" class="mg-lr-16"></u-gap>
          <fsection :title="title.receiveInformation" :customStyle="customConStyle"></fsection>
        </view>
        <u-form-item label="收件人" prop="receiver">
          <u-input placeholder="请输入" v-model="baseInfo.receiver"></u-input>
        </u-form-item>
        <u-form-item label="收件人电话" prop="receiverTel">
          <u-input type="number" placeholder="请输入" v-model="baseInfo.receiverTel"></u-input>
        </u-form-item>
        <u-form-item label="收件时间">
          <u-input
            placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="baseInfo.receiverTime"
            @click="receiveDateRange = true;"
          ></u-input>
        </u-form-item>
        <u-form-item label="收件网点">
          <u-input placeholder="请输入" v-model="baseInfo.receiverSite"></u-input>
        </u-form-item>
        <u-form-item :border-bottom="false" label="收件人地址">
          <view style="display: flex; flex-direction: column; width: 100%">
            <u-input
              type="select" :disabled="true" placeholder="请选择" :custom-style="pointerStyle"
              v-model="baseInfo.receiveName" @click=" (receiveSelectShow = true)"
            ></u-input>
            <u-line :color="$theme.u_border_color" style="margin-top: 20rpx"></u-line>
          </view>
        </u-form-item>
        <u-form-item prop="address">
          <u-input :border="true" placeholder="收件人详细地址" v-model="baseInfo.receiverAddress"></u-input>
        </u-form-item>
        <u-form-item label="备注" :border-bottom="false">
          <u-input placeholder="请输入" type="textarea" v-model="baseInfo.remark"></u-input>
        </u-form-item>
      </u-form>
    </view>
    <view class="u-form">
      <u-gap :height="$theme.cm_section_top_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
      <fsection :title="title.images" :customStyle="customStyle"></fsection>
    </view>
    <view class="u-form-m pl-10">
      <m-upload
        :uploadParam="fileUploadParam" upApiUrl="uploadBase64ForApp" :fileList="fileList"
        @on-list-change="changeUpload"
      ></m-upload>
    </view>
    <view class="submit-btns bottom-btns">
      <u-button class="del" type="primary" @click="mySimpleCase">
        保&nbsp;&nbsp;&nbsp;&nbsp;存
      </u-button>
    </view>
    <u-popup mode="bottom" height="80%" v-model="nativeNameSelectShow">
      <area-select :choiceAll="true" @choose="nativeNameSelectShowComfir"></area-select>
    </u-popup>
    <!-- 寄件 -->
    <u-calendar max-date="2099-12-31" v-model="dateRange" @change="handlerSearchDate"></u-calendar>
    <u-popup mode="bottom" height="80%" v-model="issueSelectShow">
      <area-select :choiceAll="true" @choose="issueSelectShowComfir"></area-select>
    </u-popup>
    <!-- 接收 -->
    <u-calendar max-date="2099-12-31" v-model="receiveDateRange" @change="handlerReceiveDate"></u-calendar>
    <u-popup mode="bottom" height="80%" v-model="receiveSelectShow">
      <area-select :choiceAll="true" @choose="receiveSelectShowComfir"></area-select>
    </u-popup>
    <!-- 揽件 -->
    <u-calendar max-date="2099-12-31" v-model="packageDateRange" @change="handlerPackageDate"></u-calendar>
    <!-- 派件 -->
    <u-calendar max-date="2099-12-31" v-model="dispatchDateRange" @change="handlerDispatchDate"></u-calendar>
    <u-popup mode="bottom" height="80%" v-model="dispatchSelectShow">
      <area-select :choiceAll="true" @choose="dispatchSelectShowComfir"></area-select>
    </u-popup>
  </view>
</template>

<script>
import fsection from '@/components/form-section.vue';
import MUpload from '@/components/m-upload.vue';
import intelligenceservice from '@/service/intelligence/intelligence.service';
import { uuid, } from '@/common/util.js';
import areaSelect from '@/components/area-select.vue';
import AutoInput from '@/components/autoInput.vue';
export default {
  components: {
    fsection,
    MUpload,
    areaSelect,
    AutoInput,
  },
  data() {
    return {
      rules: {
        billCode: [
          {
            required: true,
            message: '请输入单号',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
        getPerson: [
          {
            message: '查获人格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
                return regs.test(value);
              }
            },
          },
        ],
        sender: [
          {
            message: '寄件人格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
                return regs.test(value);
              }
            },
          },
        ],
        packager: [
          {
            message: '揽件人格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
                return regs.test(value);
              }
            },
          },
        ],
        dispatcher: [
          {
            message: '派件人格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
                return regs.test(value);
              }
            },
          },
        ],
        receiver: [
          {
            message: '收件人格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
                return regs.test(value);
              }
            },
          },
        ],
        getPersonTel: [
          {
            message: '电话格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                return this.$u.test.mobile(value) || this.$u.test.tel(value);
              }
            },
          },
        ],
        sendTel: [
          {
            message: '电话格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                return this.$u.test.mobile(value) || this.$u.test.tel(value);
              }
            },
          },
        ],
        packagerTel: [
          {
            message: '电话格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                return this.$u.test.mobile(value) || this.$u.test.tel(value);
              }
            },
          },
        ],
        dispatcherTel: [
          {
            message: '电话格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                return this.$u.test.mobile(value) || this.$u.test.tel(value);
              }
            },
          },
        ],
        receiverTel: [
          {
            message: '电话格式不正确！',
            trigger: ['change', 'blur',],
            validator: (rule, value, callback) => {
              if (this.$u.test.isEmpty(value)) {
                return true;
              }
              {
                return this.$u.test.mobile(value) || this.$u.test.tel(value);
              }
            },
          },
        ],
      },
      customStyle: {
        padding: '20rpx 32rpx',
      },
      customConStyle: {
        padding: '20rpx 0',
      },
      fileUploadParam: {
        fiGroupCode: this.$FILE_GROUP_TYPE.k_transport_attr,
        bizId: '',
      },
      baseInfo: {
        billCode: '',
        orgName: '',
        orgUuid: '',
        uuid: '',
        provCode: '',
        cityCode: '',
        dispatchName: '',
        menuCode: '',
      },
      nativeNameSelectShow: false,
      labelStyle: {
        fontWeight: 400,
        color: this.$theme.u_main_color,
        fontSize: '.75rem',
      },
      iconstlye: {
        fontSize: '40rpx',
        color: this.$theme.u_type_primary,
      },
      title: {
        images: '图片信息',
        tag: '关联产品',
        baseInfo: '基本信息',
        sendInformation: '发件信息',
        receiveInformation: '收件信息',
        connectMsg: '面单档案维护',
      },
      fileList: [],
      dateRange: false,
      issueSelectShow: false,
      receiveDateRange: false,
      receiveSelectShow: false,
      packageDateRange: false,
      dispatchDateRange: false,
      dispatchSelectShow: false,
      user: this.$store.state.userInfo,
      isDisabled: false,
      tt: '',
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx start
			pointerStyle: {
			  marginRight: "5px",
				pointerEvents: "none !important"
			},
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx end
    };
  },
  onReady() {
    this.$refs.uForm.setRules(this.rules);
    this.getListViewTop();
  },
  onLoad(opt) {
    this.from = opt.from;
    if (this.from === 'edit') {
      this.baseInfo = this.getRouteParam();
      this.isDisabled = false;
      this.baseInfo.provCityCountyName =
					this.$store.state.areaObj[this.baseInfo.getCountyCode] ||
					this.$store.state.areaObj[this.baseInfo.getCityCode] ||
					this.$store.state.areaObj[this.baseInfo.getProvCode] ||
					'';
      this.baseInfo.issueName =
					this.$store.state.areaObj[this.baseInfo.sendCountyCode] ||
					this.$store.state.areaObj[this.baseInfo.sendCityCode] ||
					this.$store.state.areaObj[this.baseInfo.sendProvCode] ||
					'';
      this.baseInfo.dispatchName =
					this.$store.state.areaObj[this.baseInfo.dispatcherCountyCode] ||
					this.$store.state.areaObj[this.baseInfo.dispatcherCityCode] ||
					this.$store.state.areaObj[this.baseInfo.dispatcherProvCode] ||
					'';
      this.baseInfo.receiveName =
					this.$store.state.areaObj[this.baseInfo.receiverCountyCode] ||
					this.$store.state.areaObj[this.baseInfo.receiverCityCode] ||
					this.$store.state.areaObj[this.baseInfo.receiverProvCode] ||
					'';
      // if (this.$u.test.isEmpty(this.baseInfo.getCityCode) && this.$u.test.isEmpty(this.baseInfo.getCountyCode)) {
      //   this.baseInfo.provCityCountyName = this.baseInfo.getProvCodeName;
      // } else if (this.$u.test.isEmpty(this.baseInfo.getCountyCode)) {
      //   this.baseInfo.provCityCountyName = this.baseInfo.getProvCodeName + "/" + this.baseInfo.getCityCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.getCountyCode)){
      //   this.baseInfo.provCityCountyName = this.baseInfo.getProvCodeName + "/" + this.baseInfo.getCityCodeName + "/" + this.baseInfo.getCountyCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.getProvCode)){
      //   this.baseInfo.provCityCountyName = "";
      // }
      // if (this.$u.test.isEmpty(this.baseInfo.sendCityCode) && this.$u.test.isEmpty(this.baseInfo.sendCountyCode)) {
      //   this.baseInfo.issueName = this.baseInfo.sendProvCodeName;
      // } else if (this.$u.test.isEmpty(this.baseInfo.sendCountyCode)) {
      //   this.baseInfo.issueName = this.baseInfo.sendProvCodeName + "/" + this.baseInfo.sendCityCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.sendCountyCode)){
      //   this.baseInfo.issueName = this.baseInfo.sendProvCodeName + "/" + this.baseInfo.sendCityCodeName + "/" + this.baseInfo.sendCountyCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.sendProvCode)){
      //   this.baseInfo.issueName = "";
      // }
      // if (this.$u.test.isEmpty(this.baseInfo.dispatcherCityCode) && this.$u.test.isEmpty(this.baseInfo.dispatcherCountyCode)) {
      //   this.baseInfo.dispatchName = this.baseInfo.dispatcherProvCodeName;
      // } else if (this.$u.test.isEmpty(this.baseInfo.dispatcherCountyCode)) {
      //   this.baseInfo.dispatchName = this.baseInfo.dispatcherProvCodeName + "/" + this.baseInfo.dispatcherCityCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.dispatcherCountyCode)){
      //   this.baseInfo.dispatchName = this.baseInfo.dispatcherProvCodeName + "/" + this.baseInfo.dispatcherCityCodeName + "/" + this.baseInfo.dispatcherCountyCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.dispatcherProvCode)){
      //   this.baseInfo.dispatchName = "";
      // }
      // if (this.$u.test.isEmpty(this.baseInfo.receiverCityCode) && this.$u.test.isEmpty(this.baseInfo.receiverCountyCode)) {
      //   this.baseInfo.receiveName = this.baseInfo.receiverProvCodeName;
      // } else if (this.$u.test.isEmpty(this.baseInfo.receiverCountyCode)) {
      //   this.baseInfo.receiveName = this.baseInfo.receiverProvCodeName + "/" + this.baseInfo.receiverCityCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.receiverCountyCode)){
      //   this.baseInfo.receiveName = this.baseInfo.receiverProvCodeName + "/" + this.baseInfo.receiverCityCodeName + "/" + this.baseInfo.receiverCountyCodeName;
      // } else if (!this.$u.test.isEmpty(this.baseInfo.receiverProvCode)){
      //   this.baseInfo.receiveName = "";
      // }
      try {
        this.baseInfo.sendTime = this.baseInfo.sendTime.substr(0, 10);
      } catch (e) {
        this.baseInfo.sendTime = '';
      }
      try {
        this.baseInfo.packagerTime = this.baseInfo.packagerTime.substr(0, 10);
      } catch (e) {
        this.baseInfo.packagerTime = '';
      }
      try {
        this.baseInfo.dispatcherTime = this.baseInfo.dispatcherTime.substr(0, 10);
      } catch (e) {
        this.baseInfo.dispatcherTime = '';
      }
      try {
        this.baseInfo.receiverTime = this.baseInfo.receiverTime.substr(0, 10);
      } catch (e) {
        this.baseInfo.receiverTime = '';
      }
      this.fileUploadParam.bizId = this.baseInfo.uuid;
      let params = {
        bizId: this.baseInfo.uuid,
        group: this.$FILE_GROUP_TYPE.k_transport_attr,
        menuCode: null,
      };
      intelligenceservice.findFilesByBizIdAndGroup(params).then((res) => {
        if (res.success) {
          this.fileList = res.data;
        }
      });
    } else {
      this.baseInfo.uuid = uuid();
      this.fileUploadParam.bizId = this.baseInfo.uuid;
      if (this.user.orgLevel === 1) {
        this.baseInfo.orgName = this.user.provOrgName;
        this.baseInfo.orgUuid = this.user.provOrgUuid;
      } else {
        this.baseInfo.orgName = this.user.townOrgName;
        this.baseInfo.orgUuid = this.user.townOrgUuid;
      }
    }
  },
  mounted() {},
  methods: {
    // 上传/删除图片事件
    changeUpload(list, key) {
      if (list.length > 0) {
        this.fileList = [...list,];
      } else {
        this.fileList = [];
      }
    },
    scanClick() {
      // #ifdef H5-DINGDING || H5-EMP
      this.$deviceApi
        .barCode()
        .then((res) => {
          if (res.success) {
            console.log(res);
          }
        })
        .catch((err) => {
          this.$u.toast('扫描失败');
        });
      // #endif
      // #ifndef H5-DINGDING
      this.$modal.toast('使用钉钉打开');
      // #endif
    },
    // 获取省
    nativeNameSelectShowComfir(areas) {
      if (this.$u.test.isEmpty(areas[0].admdivCode) && this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.provCityCountyName = areas[0].proName;
      } else if (this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.provCityCountyName = areas[0].proName + '/' + areas[0].admdivName;
      } else if (!this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.provCityCountyName = areas[0].proName + '/' + areas[0].admdivName + '/' + areas[0].countryName;
      }
      this.baseInfo.getProvCode = areas[0].proCode;
      this.baseInfo.getCityCode = areas[0].admdivCode;
      this.baseInfo.getCountyCode = areas[0].countryCode;
      this.baseInfo.provCityCounty = areas;
      this.nativeNameSelectShow = false;
    },
    // 派件省市区
    dispatchSelectShowComfir(areas) {
      if (this.$u.test.isEmpty(areas[0].admdivCode) && this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.dispatchName = areas[0].proName;
      } else if (this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.dispatchName = areas[0].proName + '/' + areas[0].admdivName;
      } else if (!this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.dispatchName = areas[0].proName + '/' + areas[0].admdivName + '/' + areas[0].countryName;
      }
      this.baseInfo.dispatcherProvCode = areas[0].proCode;
      this.baseInfo.dispatcherCityCode = areas[0].admdivCode;
      this.baseInfo.dispatcherCountyCode = areas[0].countryCode;
      this.dispatchSelectShow = false;
    },
    // 收件省市区
    receiveSelectShowComfir(areas) {
      if (this.$u.test.isEmpty(areas[0].admdivCode) && this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.receiveName = areas[0].proName;
      } else if (this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.receiveName = areas[0].proName + '/' + areas[0].admdivName;
      } else if (!this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.receiveName = areas[0].proName + '/' + areas[0].admdivName + '/' + areas[0].countryName;
      }
      this.baseInfo.receiverProvCode = areas[0].proCode;
      this.baseInfo.receiverCityCode = areas[0].admdivCode;
      this.baseInfo.receiverCountyCode = areas[0].countryCode;
      this.receiveSelectShow = false;
    },
    // 寄件
    issueSelectShowComfir(areas) {
      if (this.$u.test.isEmpty(areas[0].admdivCode) && this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.issueName = areas[0].proName;
      } else if (this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.issueName = areas[0].proName + '/' + areas[0].admdivName;
      } else if (!this.$u.test.isEmpty(areas[0].countryCode)) {
        this.baseInfo.issueName = areas[0].proName + '/' + areas[0].admdivName + '/' + areas[0].countryName;
      }
      this.baseInfo.sendProvCode = areas[0].proCode;
      this.baseInfo.sendCityCode = areas[0].admdivCode;
      this.baseInfo.sendCountyCode = areas[0].countryCode;
      this.issueSelectShow = false;
    },
    handlerSearchDate(e) {
      this.baseInfo.sendTime = e.result;
    },
    handlerReceiveDate(e) {
      this.baseInfo.receiverTime = e.result;
    },
    handlerPackageDate(e) {
      this.baseInfo.packagerTime = e.result;
    },
    handlerDispatchDate(e) {
      this.baseInfo.dispatcherTime = e.result;
    },
    getListViewTop() {
      this.$u.getRect('.case-search-lay').then((res) => {
        this.listViewTop = this.$u.sys().statusBarHeight + res.top + res.height + 'px';
      });
      this.$u.getRect('.submit-btns').then((res) => {
        this.bottomOffset = this.$u.sys().screenHeight - res.top + 'px';
      });
    },
    searchData(txt) {
      let params = {
        page: 1,
        limit: 10,
        paras: {
          orgUuid: this.curUser.user.org.parentOrgUuid,
          expressCompanyName: txt,
        },
      };
      return new Promise((resolve, reject) => {
        intelligenceservice
          .queryExpressMap(params)
          .then((res) => {
            if (res.success) {
              let tmp = res.data;
              tmp.forEach((itm) => {
                itm.name = [itm.expressCompanyName,].join('');
                itm.id = itm.uuid;
              });
              resolve(tmp);
            } else {
              resolve([]);
            }
          })
          .catch((err) => {
            resolve([]);
          });
      });
    },
    choiceAutoItem(itm, index) {
      if (index == '1') {
        this.baseInfo.expressCompanyName = itm.expressCompanyName;
        this.baseInfo.expressUuid = itm.uuid;
      }
    },
    mySimpleCase() {
      this.$refs.uForm.validate((valid) => {
        if (valid) {
          let params = this.baseInfo;
          this.$modal.showLoading('保存中...');
          intelligenceservice
            .saveOrUpdate(params)
            .then((res) => {
              this.$modal.hideLoading();
              if (res.success) {
                this.baseInfo = res.data;
                this.backPrev({
                  paramKey: 'refresh',
                  param: true,
                });
              } else {
                this.$u.toast(res.msg);
              }
            })
            .catch((err) => {
              this.$modal.hideLoading();
              console.log(err);
              this.$u.toast(err.msg);
            });
        } else {
          console.log('验证失败');
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
	@import './add.scss';
	.fsection {
		width: 75% !important;
	}
	.choice {
		position: relative;
		top: 20rpx;
		float: right;
	}
	.tag {
		margin-right: 10rpx;
	}
	.td {
		overflow: hidden;
	}
	/deep/.u-td {
		height: auto !important;
	}
	.btn {
		position: fixed;
		bottom: 62rpx;
		margin: auto;
		left: 60rpx;
		right: 60rpx;
		z-index: 100;
		background-color: #ffffff;
	}
	.mg-lr-16 {
		margin: 0 -32rpx !important;
	}
</style>
